<%@page import="com.wodwl.entity.Category"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="com.wodwl.entity.User"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<%@include file="../templete/header.jsp" %>
	
	<script type="text/javascript">
		function modify(id,cid){
			var item=document.getElementById(id);
			var cname=item.innerHTML
			item.innerHTML="<form action=\"/blog/category_modify.do\" method=\"post\">   <input type=\"hidden\" name=\"cid\" value=\""+cid+"\"><input type=\"text\" name=\"cname\" value=\""+cname+"\"><input type=\"submit\" value=\"提交\"></form>";
		}
		function del(id,cid){
			var item=document.getElementById(id);
			var cname=item.innerHTML
			if (confirm("您确定要删除分类"+cname))
				  window.location='/blog/category_delete.do?cid='+cid;
		}
		
	</script>
</head>
<body >
<%pageContext.setAttribute("linkType","2");%>
<%@include file="../templete/user_info.jsp"  %>
	<% 
	List<Category> categories=(List<Category>) request.getAttribute("categories");

%>
		
		<div class="conR">
			<div class="conR-hd">
				<h3>博客列表 
					<%for(int i=0;i<40;i++){ %>
					&nbsp;
					<%} %>
				 	<a href="/blog/blog_add_view.do?username=<%=user.getUsername()%>"><font color="green">撰写博客</font></a>
				 </h3>
				
			</div>


			<div class="oauth-sum-list">
				<div class="oauth-sum-listinfo">
					<table>
						<tbody>
						<tr>
							<form action="/blog/category_add.do" method="post">
								<td>添加分类：<input type="text" name="cname" ><input type="submit" value="添加"></td>
								<td></td>
							</form>
						</tr>
			<%
				if(categories!=null)
				for (int i = 0; i < categories.size(); i++) {
					Category item = categories.get(i);
			%>

							<tr>
								<td>
									<span id="c<%=i%>"><%=item.getCname() %></span>&nbsp;&nbsp;&nbsp;&nbsp;
									共<%=item.getCount() %>篇博客
								</td>
								<td>
									<input type="button" value="查看" onclick="del('c<%=i%>','<%=item.getCid()%>')">|
									<input type="button" value="修改" onclick="modify('c<%=i%>','<%=item.getCid()%>')">|
									<input type="button" value="删除" onclick="del('c<%=i%>','<%=item.getCid()%>')">
									
									
								</td>
							</tr>
	
			<%
				}
			%>
							

						</tbody>
					</table>
					
				</div>

				<p class="pager-wrap pageList">
					<span class="pageList-cur">1</span> <a href="#" class="link-lb">2</a>
					<a href="#" class="link-lb">3</a> <a class="link-lb" href="#">下一页</a>
				</p>
			</div>
		</div>
	</div>

<jsp:include page="../templete/footer.jsp"></jsp:include>

</body>
</html>